<!-- 子组件 -->
<template>
    <div>
        <h3>Child</h3>
        <button @click="fn">parent</button>
        <hr>
        <Son></Son>
    </div>
</template>

<script>
import Son from "@/components/Son.vue";

export default {
    name: "Child",
    components: {
        Son
    },
    methods: {
        fn() {
            console.log(this.$parent)  // VueComponent 父组件的实例
            console.log(this.$parent.num)
            if (this.$parent.addNum) this.$parent.addNum()
        }
    }
}
</script>